<template>
  <div>
    <div class="lookDetail" v-loading="loading">
      <div class="flex item" v-if="form.studyHour">
        <div class="item_label">
          {{ selectedType == 1 ? '任务学时' : '学时' }}
        </div>
        <div style="white-space: pre-wrap" class="item_value">
          {{ form.studyHour ? form.studyHour : 0 }} 时
        </div>
      </div>
      <div v-if="selectedType == 1 && form.description" class="flex item">
        <div class="item_label">任务描述</div>
        <div
          style="white-space: pre-wrap"
          class="item_value"
          v-html="form.description"
        ></div>
      </div>
      <div class="flex item" v-if="form.target">
        <div class="item_label">{{ selectedType == 1 ? '任务目标' : '目标' }}</div>
        <div
          style="white-space: pre-wrap"
          class="item_value"
          v-html="form.target"
        ></div>
      </div>
      <div class="flex item" v-if="form.other">
        <div class="item_label">其他</div>
        <div
          style="white-space: pre-wrap"
          class="item_value"
          v-html="form.other"
        ></div>
      </div>
      <div class="flex item" v-for="(item,index) in form.indexParamList" :key="index">
        <div class="item_label">
          {{ item.label }}
        </div>
        <div
          style="white-space: pre-wrap"
          class="item_value"
          v-html="item.value"
        ></div>
      </div>
      <div v-if="!form.other && !form.studyHour && !form.target && !form.description && form.indexParamList.length==0">
        <el-empty description="暂无信息~" style=""></el-empty>
      </div>
    </div>
  </div>
</template>

<script>
import { getIndexStudyInfo } from '@/api/home'

export default {
  components: {},
  props: {
    //判断修改  还是详情 还是新增
    type: String,
    //判断任务还是目录   1  任务    2  目录
    selectedType: [String, Number],
    selectedTaskId: [String, Number],
    courseStuId: [String, Number]
  },
  data() {
    return {
      loading: false,
      // 表单参数
      form: {
        studyHour: undefined,
        target: '',
        description: '',
        indexParamList: []
      }
    }
  },
  created() {

  },
  beforeDestroy() {

  },
  watch: {
    selectedTaskId: {
      handler() {
        this.reset()
        this.getInfo()
      },
      immediate: true
    }
  },
  methods: {
    /* 获取章节信息(分草稿和正式课程) */
    async getInfo() {
      this.loading = true
      let res = await getIndexStudyInfo(this.courseStuId, this.selectedTaskId)
      const { code, data } = res
      if (code == 200) {
        this.loading = false
        this.form = data
      }
    },
    // 表单重置
    reset() {
      this.form = {
        studyHour: undefined,
        target: '',
        description: '',
        indexParamList: []
      }
      this.resetForm('form')
    }
  }
}
</script>
<style scoped lang="scss">
.lookDetail {
  padding: 24px 0 0 40px;
  border-top: 1px solid #ebebeb;
  box-sizing: border-box;
  height: calc(100vh - 200px);
  overflow: auto;

  .item {
    margin-bottom: 32px;

    .item_label {
      margin-right: 32px;
      font-size: 16px;
      font-family: PingFangSC-Regular, PingFang SC, sans-serif;
      font-weight: 400;
      color: #999999;
      line-height: 22px;
    }

    .item_value {
      width: 696px;
      font-size: 16px;
      font-family: PingFangSC-Regular, PingFang SC, sans-serif;
      font-weight: 400;
      color: #333333;
      line-height: 22px;
      white-space: pre-wrap;
      word-wrap: break-word;
    }
  }
}

.detailbottom {
  border-top: 1px solid #ebebeb;
  height: 72px;
  box-sizing: border-box;
  padding: 0 19px 0 37px;
  align-items: center;

  ::v-deep .el-button {
    padding: 0 24px;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC, sans-serif;
    font-weight: 400;
    border-radius: 8px;
    line-height: 38px;
    height: 38px;
  }
}

.detail {
  padding: 40px 0 0 40px;
  box-sizing: border-box;
  height: calc(100vh - 310px + 77px - 72px);
  overflow: auto;
}

.edit_texteara {
  width: 640px;
}

.add_label {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 20px;

  .el-icon-plus {
    font-style: normal;
  }
}

.param_item {
  margin-bottom: 20px;

  .btns {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding: 0 40px 10px 0;
    box-sizing: border-box;
  }

  &_content {
    width: 100%;
    display: flex;
    align-items: flex-start;

    &_label {
      width: 140px;
      margin-right: 20px;
    }
  }
}

::v-deep .el-icon-delete, ::v-deep .el-icon-circle-close {
  font-style: normal;
}

//富文本回显样式
::v-deep h5,
.h5 {
  font-size: 14px;
}

::v-deep h4,
.h4 {
  font-size: 16px;
  font-weight: bold;
}

::v-deep h3,
.h3 {
  font-size: 18px;
  font-weight: bold;
}

::v-deep h2,
.h2 {
  font-size: 20px;
  font-weight: bold;
}

::v-deep h1,
.h1 {
  font-size: 22px;
  font-weight: bold;
}

::v-deep i {
  font-style: italic;
}

::v-deep .w-e-toolbar .w-e-menu i {
  font-style: normal;
}

::v-deep ol {
  list-style-type: decimal;
}

/* ul ol 样式 */
::v-deep ol {
  margin: 10px 0 10px 22px;
  list-style-type: decimal;
}

::v-deep ul {
  margin: 10px 0 10px 22px;
  list-style-type: disc;
}

/* table 样式 */
::v-deep table {
  border-top: 1px solid #ccc;
  border-left: 1px solid #ccc;
}

::v-deep table td,
::v-deep table th {
  border-bottom: 1px solid #ccc;
  border-right: 1px solid #ccc;
  padding: 3px 5px;
  height: 32px;
}

::v-deep table th {
  border-bottom: 2px solid #ccc;
  text-align: center;
  background-color: #f1f1f1;
}

/* blockquote 样式 */
::v-deep blockquote {
  display: block;
  border-left: 8px solid #d0e5f2;
  padding: 5px 10px;
  margin: 10px 0;
  line-height: 1.4;
  min-height: 24px;
  font-size: 100%;
  background-color: #f1f1f1;
}

/* code 样式 */
::v-deep code {
  display: inline-block;
  *display: inline;
  *zoom: 1;
  background-color: #f1f1f1;
  border-radius: 3px;
  padding: 3px 5px;
  margin: 0 3px;
}

::v-deep pre code {
  display: block;
}

::v-deep a {
  text-decoration: underline;
  color: #5592e5;
}
</style>
